package com.compty.paint.domain;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * @Todo:省份信息
 * @author: zhuqh
 * @CreateTime:2011-5-31 下午06:24:31
 */
@Entity
@Table(name = "t_provinceinfo")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class ProvinceInfo implements java.io.Serializable{

	private static final long serialVersionUID = -5983012099739041801L;
	
	private Long id;
	
	/************ 省份名称 ****************/
	private String name;
	
	/************ 所属国家 ****************/
	private CountryInfo countryInfo;
	
	private List<CityInfo> citys = new ArrayList<CityInfo>(0);

	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "name", length = 40,nullable=false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="countryid")
	public CountryInfo getCountryInfo() {
		return countryInfo;
	}

	public void setCountryInfo(CountryInfo countryInfo) {
		this.countryInfo = countryInfo;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "provinceInfo")
	public List<CityInfo> getCitys() {
		return citys;
	}

	public void setCitys(List<CityInfo> citys) {
		this.citys = citys;
	}
	
}
